/**
 *@description:
 *@file: game_level.h
 *@author: snow-tyan
 *@email: zziywang@163.com
 *@date: 1 February 2023
 *@copyright: 2018-2022 AiRiA. All rights reserved.
 */

#pragma once

#include <glad/glad.h>
#include <vector>
#include <memory>
#include <string>

namespace mygl {

class SpriteRenderer;

namespace game {

class GameObject;

class GameLevel {
 public:
  // Constructor
  GameLevel();
  // Loads level from file
  void Load(const std::string &filename, GLuint level_width, GLuint level_height);
  // Render level
  void Draw(std::shared_ptr<SpriteRenderer> renderer);
  // Check if the level is completed (all non-solid tiles are destroyed)
  GLboolean IsCompleted();

  auto &bricks() const { return bricks_; }

 private:
  void init(const std::vector<std::vector<GLuint>> &tile_data, GLuint level_width,
            GLuint level_height);

 private:
  std::vector<std::shared_ptr<GameObject>> bricks_;
};

}  // namespace game
}  // namespace mygl
